package cn.edu.scau.cmi.zhouxinyue.Adapter;

import java.util.ArrayList;

import javafx.fxml.FXML;

import javafx.scene.control.Button;

import javafx.scene.control.TextField;

import javafx.scene.control.TextArea;

public class classAdapterController {
	@FXML
	private TextField number;
	@FXML
	private TextField name;
	@FXML
	private TextArea show;
	@FXML
	private Button add;
	private static ArrayList<Integer> Number=new ArrayList<Integer>();
	private static ArrayList<Student> Student=new ArrayList<Student>();
	private String na;
	private int num;
	
	public void ADD() {
		num=Integer.parseInt(number.getText());
		for(int i=0;i<Number.size();i++) {
			if(num==Number.get(i)) {
				show.appendText("该学生已存在！"+'\n');
				return ;
			}
		}
		na=name.getText();
		Number.add(num);
		Student student=new Student();
		student.Name(na);
		student.Number(num);
		Student.add(student);
		classAdapter CA=new classAdapter();
		CA.sortInt(Number);
		CA.sortStudent(Number, Student);
		show.setText(null);
		for(int i=0;i<Student.size();i++) {
			show.appendText(Student.get(i).getNumber()+"    "+Student.get(i).getName()+'\n');
		}
	}

}
